mavproxy_cmdlong.py: add possibility of retrying commands #1670
Draft
peterbarker wants to merge 2 commits into
Draft
mavproxy_cmdlong.py: add possibility of retrying commands #1670peterbarker wants to merge 2 commits into
peterbarker wants to merge 2 commits into
Conversation
cclauss
approved these changes
Apr 10, 2026
Contributor
cclauss
left a comment
There was a problem hiding this comment.
Type hints please on new functions and methods.
The number of retries should always be an integer.
| z) | ||
|
|
||
| class PendingCommand(): | ||
| def __init__(self, command, retries=None, retry_interval=5): |
Contributor
There was a problem hiding this comment.
Suggested change
| def __init__(self, command, retries=None, retry_interval=5): | |
| def __init__(self, command, retries: int = 0, retry_interval: int = 5) -> None: |
| self.last_send_time = 0 | ||
| self.retry_interval = retry_interval | ||
|
|
||
| def timeout_expired(self): |
Contributor
There was a problem hiding this comment.
Suggested change
| def timeout_expired(self): | |
| def timeout_expired(self) -> bool: |
| now = time.time() | ||
| return now - self.last_send_time > self.retry_interval | ||
|
|
||
| def send(self, mav): |
Contributor
There was a problem hiding this comment.
Suggested change
| def send(self, mav): | |
| def send(self, mav) -> None: |
| self.send_count += 1 | ||
| self.last_send_time = time.time() | ||
|
|
||
| def dead(self): |
Contributor
There was a problem hiding this comment.
Suggested change
| def dead(self): | |
| def dead(self) -> None: |
| def dead(self): | ||
| if not self.timeout_expired: | ||
| return False | ||
| if self.retries is None: |
Contributor
There was a problem hiding this comment.
Suggested change
| if self.retries is None: | |
| if not self.retries: |
| return True | ||
| return False | ||
|
|
||
| def run_COMMAND_INT_OR_LONG(self, command, retries=None): |
Contributor
There was a problem hiding this comment.
Suggested change
| def run_COMMAND_INT_OR_LONG(self, command, retries=None): | |
| def run_COMMAND_INT_OR_LONG(self, command, retries: int = 0) -> None: |
| self.command_queue[command.command_opaque_id] = p | ||
| p.send(self.master.mav) | ||
|
|
||
| def handle_COMMAND_ACK(self, m): |
Contributor
There was a problem hiding this comment.
Suggested change
| def handle_COMMAND_ACK(self, m): | |
| def handle_COMMAND_ACK(self, m) -> None: |
| return | ||
| del self.command_queue[m.command_opaque_id] | ||
|
|
||
| def retry_commands(self): |
Contributor
There was a problem hiding this comment.
Suggested change
| def retry_commands(self): | |
| def retry_commands(self) -> None: |
| continue | ||
| del self.command_queue[opaque_id] | ||
|
|
||
| def idle_task(self): |
Contributor
There was a problem hiding this comment.
Suggested change
| def idle_task(self): | |
| def idle_task(self) -> None: |
| self.retry_commands() | ||
| self.last_command_retry_ms = now | ||
|
|
||
| def mavlink_packet(self, m): |
Contributor
There was a problem hiding this comment.
Suggested change
| def mavlink_packet(self, m): | |
| def mavlink_packet(self, m) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See mavlink/mavlink#2364